/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @signatureAlgorithm = 'v2';
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('um-test', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model GetOssUploadParamRequest {
  appVersion?: string(name='appVersion', example='1.0.3'),
  dataSourceId?: string(name='dataSourceId', example='5fb6001a73749c24fd9cb356'),
  fileName?: string(name='fileName', example='symbol.zip'),
  fileType?: int32(name='fileType', example='1'),
}

model GetOssUploadParamResponseBody = {
  requestId?: string(name='RequestId', example='4E442FB6-90AE-505E-84FD-8CEF655A0FDF'),
  code?: long(name='code', description='code', example='code'),
  data?: {
    accessKeyId?: string(name='accessKeyId', example='accessKeyId'),
    callback?: string(name='callback', example='callback'),
    key?: string(name='key', example='key'),
    policy?: string(name='policy', example='policy'),
    signature?: string(name='signature', example='signature'),
    uploadAddress?: string(name='uploadAddress', example='https://quickbird.oss-cn-shanghai.aliyuncs.com'),
  }(name='data', description='data'),
  msg?: string(name='msg', example='msg'),
  success?: boolean(name='success', example='success'),
  traceId?: string(name='traceId', description='traceId', example='traceId'),
}

model GetOssUploadParamResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetOssUploadParamResponseBody(name='body'),
}

async function getOssUploadParamWithOptions(request: GetOssUploadParamRequest, runtime: Util.RuntimeOptions): GetOssUploadParamResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetOssUploadParam',
    version = '2021-10-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getOssUploadParam(request: GetOssUploadParamRequest): GetOssUploadParamResponse {
  var runtime = new Util.RuntimeOptions{};
  return getOssUploadParamWithOptions(request, runtime);
}

model UploadNotaryResponseBody = {
  code?: long(name='code', description='code', example='code'),
  data?: string(name='data', example='[{\\"selected\\": True, \\"able\\": True, \\"multiType\\": \\"multiUnit\\"}, {\\"selected\\": True, \\"able\\": True, \\"multiType\\": \\"multiCell\\"}, {\\"selected\\": False, \\"able\\": True, \\"multiType\\": \\"readMultiUnit\\"}]'),
  detailMsg?: string(name='detailMsg', example='msg'),
  msg?: string(name='msg', example='msg'),
}

model UploadNotaryResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UploadNotaryResponseBody(name='body'),
}

async function uploadNotaryWithOptions(runtime: Util.RuntimeOptions): UploadNotaryResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'UploadNotary',
    version = '2021-10-27',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'Anonymous',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function uploadNotary(): UploadNotaryResponse {
  var runtime = new Util.RuntimeOptions{};
  return uploadNotaryWithOptions(runtime);
}

